### Monitor Class ###

import os, ConfigParser

class Monitor:
	def __init__(self):
		''' WarningType: mail sms '''
		self.todo = {}

	def ReadConf(self, confdir, confile):
		todo = {}
		RC = ConfigParser.ConfigParser()
		RC.read('%s/%s' % (confdir, confile))

		### Read Session ###
		### now Default: Email, warning type ###
		for tmpsec in RC.sections():
			todo[tmpsec] = dict(RC.items(tmpsec))
		
		### Rebuild Job List ###
		for tmpsec in todo:
			if tmpsec == 'Default': continue
			self.todo[tmpsec] = {}
			self.todo[tmpsec].update(todo['Default'])
			self.todo[tmpsec].update(todo[tmpsec])
			
	def SplitJob(self):
		tmpjob = {}
		for sec in self.todo:
			if self.todo[sec].has_key('ipgroup'):
				for iptmp in self.todo[sec]['ipgroup'].split(','):
					tmpjob[iptmp] = {}
					tmpjob[iptmp].update(self.todo[sec])
		return tmpjob
